import JSEncrypt from "jsencrypt";
const _pubKey = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7XbcyVcZWN5idGVcl+TQCljUp
SJnS5AIyZcDQqEBNRGxHxo2lDfNlpcHktmgotu0hGC5qrWdET3UdaBi4qXuQ8x1f
X9zY9QqwczNW5t8dnGvhrmIl2QQ2wR8IB6jtwBmISdk7Snr0UgJc4tgXMoolPiaW
631xKnwvbK4fCYZfVQIDAQAB
-----END PUBLIC KEY-----`;

export function encrypt(txt) {
    var encrypt = new JSEncrypt(); // 新建JSEncrypt对象
    encrypt.setPublicKey(_pubKey);// 设置公钥
    // 加密数据
    var res = encrypt.encrypt(txt);
    return res; // 对需要加密的数据进行加密
}
